import { IFeidaoAiNodejsComponent } from '@feidao/web/interfaces';
import P01 from './P01';
import P02 from './P02';
import nodejs from '@feidao/web/atom/nodejs/msg-b/nodejs';
import server_render from '../atom/server-render';


export default async function (fd: IFeidaoAiNodejsComponent, ...args: any[]) {
	const exam_id='201801';

	const array={};

	fd.data.item_detail=array;

	fd.data.criteria = {
		exam_id
	};

	const param = {
		criteria: fd.data.criteria,
		page_size: 1,
		page_no: 0
	};

	const res = await nodejs('flippedclass', 'exam_subjects_find', param);
	console.warn('.................. student ..................', res);

	const department_no=res.dataArray[0].department_no;

	console.log('11111111111',department_no);


	fd.data.criteria = {
		department_no
	};

	console.log('11111111111',fd.data.criteria);

	const param_major = {
		criteria: {},
		page_size: 0,
		page_no: 1
	};

	const res_major = await nodejs('flippedclass', 'specialty_find', param_major);
	console.warn('.................. major ..................', res_major);

	if (res.dataArray.length === 0) {
		server_render(fd.data.node, 'P01', P01, []);
		server_render(fd.data.node, 'P02', P02, []);
	} else {
		server_render(fd.data.node, 'P01', P01, res.dataArray);
		server_render(fd.data.node, 'P02', P02, res_major.dataArray);
	}

}
